package com.fr.report.script.core.parser;

import com.fr.util.Utils;
import java.math.BigDecimal;
import java.math.BigInteger;

public abstract class MathExpression extends BinaryExpression
{
  protected Object objectBinaryOperation(Object paramObject1, Object paramObject2, String paramString)
    throws UtilEvalError
  {
    if (paramObject1 == OperationUtils.POSITIVE_INFINITY)
    {
      if (paramObject2 == OperationUtils.POSITIVE_INFINITY)
        return ccPIPI(paramString);
      if (paramObject2 == OperationUtils.NEGATIVE_INFINITY)
        return ccPINI(paramString);
      return ccPIRE(paramObject2, paramString);
    }
    if (paramObject1 == OperationUtils.NEGATIVE_INFINITY)
    {
      if (paramObject2 == OperationUtils.POSITIVE_INFINITY)
        return ccNIPI(paramString);
      if (paramObject2 == OperationUtils.NEGATIVE_INFINITY)
        return ccNINI(paramString);
      return ccNIRE(paramObject2, paramString);
    }
    if (paramObject2 == OperationUtils.POSITIVE_INFINITY)
      return ccREPI(paramObject1, paramString);
    if (paramObject2 == OperationUtils.NEGATIVE_INFINITY)
      return ccRENI(paramObject1, paramString);
    Number localNumber1 = Utils.objectToNumber(paramObject1, true);
    Number localNumber2 = Utils.objectToNumber(paramObject2, true);
    if (localNumber1 != null)
      paramObject1 = localNumber1;
    if (localNumber2 != null)
      paramObject2 = localNumber2;
    return ccRERE(paramObject1, paramObject2, paramString);
  }

  protected abstract Object ccPIPI(String paramString);

  protected abstract Object ccPINI(String paramString);

  protected abstract Object ccPIRE(Object paramObject, String paramString);

  protected abstract Object ccNIPI(String paramString);

  protected abstract Object ccNINI(String paramString);

  protected abstract Object ccNIRE(Object paramObject, String paramString);

  protected abstract Object ccREPI(Object paramObject, String paramString);

  protected abstract Object ccRENI(Object paramObject, String paramString);

  protected abstract Object ccRERE(Object paramObject1, Object paramObject2, String paramString)
    throws UtilEvalError;

  protected Object numberOperation(Object paramObject1, Object paramObject2, String paramString)
  {
    Integer localInteger1 = new Integer(0);
    Integer localInteger2 = new Integer(0);
    if ((localInteger1 instanceof BigDecimal) || (localInteger2 instanceof BigDecimal) || (localInteger1 instanceof BigInteger) || (localInteger2 instanceof BigInteger))
      return decimalOperation(new BigDecimal(localInteger1.toString()), new BigDecimal(localInteger2.toString()), paramString);
    if ((localInteger1 instanceof Double) || (localInteger2 instanceof Double) || (localInteger1 instanceof Float) || (localInteger2 instanceof Float))
      return doubleOperation(localInteger1.doubleValue(), localInteger2.doubleValue(), paramString);
    return intOperation(localInteger1.intValue(), localInteger2.intValue(), paramString);
  }

  protected abstract Object decimalOperation(BigDecimal paramBigDecimal1, BigDecimal paramBigDecimal2, String paramString);

  protected abstract Object doubleOperation(double paramDouble1, double paramDouble2, String paramString);

  protected abstract Object intOperation(int paramInt1, int paramInt2, String paramString);
}